package cn.herlioner.action;

import java.util.Map;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.SessionAware;

import cn.herlioner.dao.StudentSocialMessageDAO;
import cn.herlioner.dao.impl.StudentDAOImpl;
import cn.herlioner.dao.impl.StudentSocialMessageDAOImpl;
import cn.herlioner.pojo.Studentsocialmessage;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class Studentsocialmessagemanger extends ActionSupport implements SessionAware{
	
	public String getstudentsocialmessagemanger(){
		Map session = ActionContext.getContext().getSession();
		HttpServletRequest request = ServletActionContext.getRequest();
		Long stunum = (Long) session.get("Num");
		StudentSocialMessageDAOImpl messageDAOImpl = new StudentSocialMessageDAOImpl();
		Studentsocialmessage studentsocialmessage = messageDAOImpl.get(stunum);
		String stuname = new StudentDAOImpl().get(stunum).getStuname();
		
		request.setAttribute("stuname", stuname);
		request.setAttribute("studentsocial", studentsocialmessage);
		return "getsuccess";
	}
	
	public String SocialMessageSave(){
		HttpServletRequest request = ServletActionContext.getRequest();
		Map session = ActionContext.getContext().getSession();
		
		Studentsocialmessage studentsocialmessage = new Studentsocialmessage();
		Studentsocialmessage  studentsocial = new Studentsocialmessage();
		
		Long qq = (Long) request.getAttribute("qq");
		String mail = (String) request.getAttribute("mail");
		studentsocial.setQq(qq);
		studentsocial.setMail(mail);
		studentsocial.setStunum((long)session.get("Num"));
		
		StudentSocialMessageDAOImpl messageDAOImpl = new StudentSocialMessageDAOImpl();
		
		
		messageDAOImpl.saveSocial(studentsocial);
		return "savesuccess";
	}
	@Override
	public void setSession(Map<String, Object> arg0) {
		// TODO Auto-generated method stub
		
	}

}
